package com.tkc.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.tkc.common.enums.BaseResultCodeEnum;
import com.tkc.common.result.CommonResult;
import com.tkc.controller.util.ControllerErrorProcessor;

/**
 * 
 * @Function: 基础控制器，用于抛出json格式的异常
 * 
 * @Project :assessmenttask 
 * @Package :com.tkc.controller 
 * @File :BaseController.java 
 * @ClassName: BaseController  
 * 
 * @author tankaichao 
 * @email cgztkc@126.com 
 * @Date 2016年8月9日下午5:59:55
 * @since JDK 1.8 
 *
 */
@Controller
public class BaseController {
	
	private static final Logger log = LoggerFactory.getLogger(BaseController.class);

	@ExceptionHandler
	@ResponseBody
	public CommonResult	exceptionHandler(Exception ex){
		return ControllerErrorProcessor.exceptionProcessor(ex, log);
	}
	
	@RequestMapping("/")
	@ResponseBody
	public CommonResult welcome(){
		CommonResult result = new CommonResult (BaseResultCodeEnum.ERR_CODE_100);
		return result;
	}
}
